package com.ourteam.workspace.api;

import org.apache.commons.lang.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.workspace.dao.WorkspaceBuildConfigDAOQueryBean;
import com.ourteam.workspace.domain.WorkspaceBuildConfigBean;

public class WorkspaceBuildConfigSearchModel extends AbstractSearchModel<WorkspaceBuildConfigDAOQueryBean> {
	private long workspaceId;
	private String buildConfigName;

	public String getBuildConfigName() {
		return buildConfigName;
	}

	public void setBuildConfigName(String buildConfigName) {
		this.buildConfigName = buildConfigName;
	}

	public long getWorkspaceId() {
		return workspaceId;
	}

	public void setWorkspaceId(long workspaceId) {
		this.workspaceId = workspaceId;
	}

	@Override
	public String getMappedDAOField(String aProperty) {

		return WorkspaceBuildConfigBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(WorkspaceBuildConfigDAOQueryBean queryBean) throws Exception {

		WorkspaceBuildConfigDAOQueryBean.Criteria criteria = queryBean.createCriteria();
		if (workspaceId != 0) {
			criteria.andWorkspaceIdEqualTo(workspaceId);
		}
		if (StringUtils.isNotBlank(buildConfigName)) {
			criteria.andBuildConfigNameLike(buildConfigName);
		}
	}

}
